package com.vf.admin.miaodong.controller;

import com.vf.admin.client.service.AppMingXiShouLiService;
import com.vf.admin.client.service.AppMingXiSongLiService;
import com.vf.admin.common.BaseController;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppGiftReward;
import com.vf.admin.miaodong.entity.AppMingXiShouLi;
import com.vf.admin.miaodong.entity.AppMingXiSongLi;
import com.vf.admin.miaodong.service.AfterGiftRewardService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 礼物打赏记录
 */
@Controller
@RequestMapping("/after/giftreward")
public class AfterGiftRewardController extends BaseController{
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    AfterGiftRewardService afterGiftRewardService;
    @Autowired
    AppMingXiShouLiService appMingXiShouLiService;
    @Autowired
    AppMingXiSongLiService appMingXiSongLiService;

    /**
     * 礼物打赏记录列表
     * @param splitPageBean
     * @param startDate  开始时间
     * @param endDate  结束时间
     * @param giftname  礼物名称
     * @param dsnick   打赏人名称
     * @param dsphone  打赏人电话
     * @param nick   被打赏人名称
     * @param phone  被打赏人电话
     * @param roomcode  打赏房间
     * @return
     */
    @RequestMapping("/list")
    public String list(SplitPageBean splitPageBean,String startDate,String endDate,String giftname,String dsnick,
                       String dsphone,String nick,String phone,String roomcode){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("giftname",giftname);
            map.put("dsnick",dsnick);
            map.put("dsphone",dsphone);
            map.put("nick",nick);
            map.put("phone",phone);
            map.put("roomcode",roomcode);
            List<AppGiftReward> list = afterGiftRewardService.list(map,splitPageBean);

            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("giftname",giftname);
            request.setAttribute("dsnick",dsnick);
            request.setAttribute("dsphone",dsphone);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            request.setAttribute("roomcode",roomcode);
            return this.sucess("/web/after/giftreward/list");
        }catch (Exception e){
            logger.error("查询礼物打赏记录列表异常",e);
            return this.error("系统繁忙");
        }
    }

    @RequestMapping("/songliList")
    public String songliList(SplitPageBean splitPageBean,String startDate,String endDate,String giftname,String nick,
                       String phone){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("giftname",giftname);
            map.put("nick",nick);
            map.put("phone",phone);
            List<AppMingXiSongLi> list = appMingXiSongLiService.list(map,splitPageBean);

            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("giftname",giftname);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            return this.sucess("/web/manage/app/gift/sendgift");
        }catch (Exception e){
            logger.error("查询礼物打赏记录列表异常",e);
            return this.error("系统繁忙");
        }
    }

    @RequestMapping("/shouliList")
    public String shouliList(SplitPageBean splitPageBean,String startDate,String endDate,String giftname,String nick,
                       String phone){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("giftname",giftname);
            map.put("nick",nick);
            map.put("phone",phone);
            List<AppMingXiShouLi> list = appMingXiShouLiService.list(map,splitPageBean);

            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("giftname",giftname);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            return this.sucess("/web/manage/app/gift/collectgift");
        }catch (Exception e){
            logger.error("查询礼物打赏记录列表异常",e);
            return this.error("系统繁忙");
        }
    }

}
